package com.atguigui.leetcode;

/**
 * 1800.最大升序子数组和
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/10/7 19:35
 */
public class P1800MaximumAscendingSubarraySum {


    public static void main(String[] args) {
        Solution solution = new P1800MaximumAscendingSubarraySum().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int maxAscendingSum(int[] nums) {
            int res = 0;
            int l = 0;
            while (l < nums.length) {
                int cursum = nums[l++];
                //从左开始往右遍历，符合条件就相加
                while (l < nums.length && nums[l] > nums[l - 1]) {
                    cursum += nums[l++];
                }
                res = Math.max(res, cursum);
            }

            return res;
        }
    }
}
